package com.mcxx.modules.temporary.fundpay.service.write;

import com.mcxx.common.exception.BizException;
import com.mcxx.modules.temporary.fundpay.dao.write.TmpFundPayMemberWriteDao;
import com.mcxx.modules.temporary.fundpay.entity.TmpFundPayMemberEntity;
import com.yinhai.ta404.core.transaction.annotation.TaTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@TaTransactional
public class TmpFundPayMemberWriteService {

    @Autowired
    private TmpFundPayMemberWriteDao tmpFundPayMemberWriteDao;


    public int insert(TmpFundPayMemberEntity tmpFundPayMember) {
    	return tmpFundPayMemberWriteDao.insert(tmpFundPayMember);
    }


    public int inserts(List<TmpFundPayMemberEntity> fundPayMemberList){
        return tmpFundPayMemberWriteDao.inserts(fundPayMemberList);
    }


    public int insertIgnoreNull(TmpFundPayMemberEntity tmpFundPayMember) {
    	return tmpFundPayMemberWriteDao.insertIgnoreNull(tmpFundPayMember);
    }



    public int updateIgnoreNull(TmpFundPayMemberEntity tmpFundPayMember) {
    	return tmpFundPayMemberWriteDao.updateIgnoreNull(tmpFundPayMember);
    }



    public int deleteByFundPayIdAndFamilyId(String fundPayId,List<String> familyList) {
        return tmpFundPayMemberWriteDao.deleteByFundPayIdAndFamilyId(fundPayId,familyList);
    }



    public void deleteFundPayMember(String fundPayId, List<String> familyIdList){
        int rst = tmpFundPayMemberWriteDao.deleteByFundPayIdAndFamilyId(fundPayId, familyIdList);
        if(rst <= 0){
            throw new BizException("-1", "保障金名册删除成员失败");
        }
    }
}
